﻿using Jayden.Dll.Sc2.Descriptions;

namespace Jayden.Dll.Sc2
{
	public class Cost
	{
		private int m_Mineral;
		private int m_Vespene;
		private int m_Time;
		private int m_Supply;

		public static Cost operator +(Cost a, Cost b)
		{
			return new Cost(a.Mineral + b.Mineral, a.Vespene + b.Vespene, a.Time + b.Time, a.Supply + b.Supply);
		}

		public Cost(int mineral = 0, int vespene = 0, int time = 0, int supply = 0)
		{
			m_Mineral = mineral;
			m_Vespene = vespene;
			m_Time = time;
			m_Supply = supply;
		}
		public Cost(Cost clone)
		{
			m_Mineral = clone.m_Mineral;
			m_Vespene = clone.m_Vespene;
			m_Time = clone.m_Time;
			m_Supply = clone.m_Supply;
		}

		public int Mineral { get { return m_Mineral; } }
		public int Vespene { get { return m_Vespene; } }
		public int Time { get { return m_Time; } }
		public int Supply { get { return m_Supply; } }

		public Cost AddInput(EntityDescription entity, Cost cost)
		{
			Cost total = new Cost(this);
			total.m_Mineral += (cost.Mineral / entity.Count);
			total.m_Vespene += (cost.Vespene / entity.Count);
			total.m_Time += (cost.Time / entity.Count);
			return total;
		}


		public override string ToString()
		{
			return string.Format("M:{0}|V:{1}|T:{2}|S:{3}", m_Mineral, m_Vespene, m_Time, m_Supply);
		}
	}
}
